/*
 * @Author: your name
 * @Date: 2021-04-17 17:35:51
 * @LastEditTime: 2021-04-17 23:29:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-xmll\src\store\detail.js
 */
/*
 * @Author: your name
 * @Date: 2021-04-17 14:36:46
 * @LastEditTime: 2021-04-17 23:26:56
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-xmall\src\store\detail.js
 */
import { getProductDetail, deteleProduct } from '@/api/index'
const state = {
  detail: {}
}
const mutations = {
  RECEIVED_DETAIL (state, detail) {
    state.detail = detail
  },
  RESET_PRODUCE (state) {
    state.detail = {}
  }
}
const actions = {
  async getDetailData ({ commit }, goodsId) {
    const resove = await getProductDetail(goodsId)
    if (resove.code === 200) {
      commit('RECEIVED_DETAIL', resove.data)
    }
  },
  // 删除当前选择的商品
  async deteleProduct ({ commit }, goodsId) {
    const result = await deteleProduct(goodsId)
    commit('RESET_PRODUCE')
  }
}
const getters = {

}
export default {
  state,
  mutations,
  actions,
  getters
}